var express = require("express");
var router = express.Router();
var multer = require("multer");
var fs = require("fs");

var upload = multer({
  "dest":"uploads/"
})
const arr = [];
router.get("/img/:filename", function(req,res){
  fs.createReadStream("uploads/"+req.params.filename).pipe(res);
});

router.get("/",function(req,res){
  res.locals.list = arr;
  res.render("lesson14");
});

router.post("/upload", upload.single('myfile'), function(req,res){
  arr.push(req.file);
  res.redirect("back");
});



module.exports = router;
